<template>
  <el-card style="width: 600px">

    <el-form label-width="90" size="small">
      <el-form-item label="用户名">
        <el-input v-model="form.username" autocomplete="off" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="昵称">
        <el-input v-model="form.nickname" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="form.email" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="电话">
        <el-input v-model="form.phone" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>

  </el-card>
</template>

<script>
export default {
  name: "Person",
  data() {
    return {
      form: {},
      user: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {}
              //三目运算符  检测是否有user 进行判断，有该user就将它转化成json，没有该对象则返回空

    }
  },
  created(){
    this.request.get("/user/username/" + this.user.username).then(res => {
      if (res.code === '200'){
        this.form= res.data
      }
    })
  },
  methods:{
    save() {
      this.request.post("/user/",this.form).then(res =>{
        if(res.data){
          this.$message.success("修改成功")
        }else {
          this.$message.error("修改失败")
        }
      })
    },
  }
}
</script>

<style>
.avatar-uploader {
  text-align: center;
  padding-bottom: 10px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radivs: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 138px;
  height: 138px;
  line-height: 138px;
  text-align: center;
}

.avatar {
  width: 138px;
  height: 138px;
  display: block;
}
</style>